class MinStack {
public:
    stack<int> num;
    deque<int> minnum;
    MinStack() {
    }
    void push(int val) {
        num.push(val);
        if(minnum.empty()||val<=minnum.front())minnum.push_front(val);
    }
    void pop() {
        int topnum=num.top();
        num.pop();
        if(topnum==minnum.front())minnum.pop_front();
        
    }
    int top() {
        return num.top();
    }
    int getMin() {
        return minnum.front();
    }
};
